package top.ranzhang.service.impl;

import com.baomidou.mybatisplus.extension.toolkit.Db;
import top.ranzhang.bean.entity.AttendanceRecords;
import top.ranzhang.mapper.AttendanceRecordsMapper;
import top.ranzhang.service.IAttendanceRecordsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ran
 * @since 2025-06-05
 */
@Service
public class AttendanceRecordsServiceImpl extends ServiceImpl<AttendanceRecordsMapper, AttendanceRecords> implements IAttendanceRecordsService {

    @Override
    public Object getAll() {
        List<AttendanceRecords> list = Db.lambdaQuery(AttendanceRecords.class).list();
        return list;
    }

    @Override
    public void update(AttendanceRecords attendanceRecord) {
        Db.lambdaUpdate(AttendanceRecords.class).update(attendanceRecord);
    }

    @Override
    public Object getByIds(Long id) {
        AttendanceRecords attendanceRecord = Db.lambdaQuery(AttendanceRecords.class).eq(AttendanceRecords::getAttendanceId, id).one();
        return attendanceRecord;
    }

    @Override
    public void delete(Long id) {

        Db.lambdaUpdate(AttendanceRecords.class).eq(AttendanceRecords::getAttendanceId, id).remove();
    }

    @Override
    public Integer getAttendanceCount() {
        Long count = Db.lambdaQuery(AttendanceRecords.class).count();
        return count.intValue();
    }
}
